<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\dao\car;


use app\dao\BaseDao;
use app\model\car\CarUpkeep;

class CarUpkeepDao extends BaseDao
{
    /**
     * @return string
     */
    protected function setModel(): string
    {
        return CarUpkeep::class;
    }

    /**
     * 列表
     * @param array $where
     * @param int $page
     * @param int $limit
     * @return array
     */
    public function getList(array $where = [],int $page,int $limit){
        $model = $this->getModel()->alias('u')->where('u.is_del',0);
        $model = $model->field('u.*,i.car_no');
        $model = $model->join('car_info i','i.id=u.car_id','left');
        if(isset($where['keyword'])&&$where['keyword']){
            $model->where('i.car_no','like',"%{$where['keyword']}%");
        }
        $count = $model->count();
        $list = $model->order('id desc')->page($page,$limit)->select()->toArray();
        return compact('list','count');
    }
}
